package com.usian.consumerlogin.controller;

import cn.hutool.json.JSON;
import com.usian.consumerlogin.feign.*;
import com.usian.consumerlogin.pojo.Consumer;
import com.usian.consumerlogin.pojo.Result;
import com.usian.model.Race;
import com.usian.model.RaceDto;
import com.usian.model.RaceTeam;
import com.usian.model.Xzda;
import com.usian.vo.CatalogDto;
import com.usian.vo.CourseDto;
import com.usian.vo.ResultResopnse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("consumer")
public class ConsumerController {
    @Autowired
    private FeignConsumer feignConsumer;
    @Autowired
    private FeignTrain feignTrain;
    @Autowired
    private FeignRace feignRace;
    @Autowired
    private FeignCourse feignCourse;
    @Autowired
    private FeignCategory feignCategory;
    @Autowired
    private FeignLabel feignLabel;




    @RequestMapping("login")
    public Result login(@RequestBody Consumer consumer) {
        return feignConsumer.userLogin(consumer);
    }

    //     我的培训
    @RequestMapping("trainCount")
    public Result trainCount(Integer consumerId) {
        return feignTrain.trainCount(consumerId);
    }

    //    我的竞赛
    @RequestMapping("raceCount")
    public Result raceCount(Integer consumerId) {
        return feignRace.raceCount(consumerId);
    }
    //    我的课程
    @RequestMapping("courseCount")
    public Result courseCount(Integer consumerId) {
        return feignTrain.courseCount(consumerId);
    }
    //    我的课程
    @RequestMapping("findAllOne")
    public Result findAllOne() {
        return feignCourse.findAllOne();
    }
    //   点赞
    @RequestMapping("dianzan")
    public Result dianzan(@RequestParam Integer id,@RequestParam Integer consumerId) {
        return feignCourse.dianzan(id,consumerId);
    }
    //  最新课程
    @RequestMapping("LatestCourse")
    public Result latestCourse() {
        return feignCourse.LatestCourse();
    }
    //  最新培训时间
    @RequestMapping("LatestTrain")
    public Result latestTrain() {
        return feignTrain.LatestTrain();
    }
    //  最新测验
    @RequestMapping("LatestQuiz")
    public Result latestQuiz() {
        return feignCategory.LatestQuiz();
    }

    //  查询所有课程
    @RequestMapping("consumerFindAll")
    public Result consumerFindAll(@RequestBody CourseDto courseDto,@RequestParam String lib) {
        return feignCourse.findAll(courseDto,lib);
    }
    //  查询所有课程
    @RequestMapping("labelFindAll")
    public ResultResopnse labelFindAll() {
        return feignLabel.findAll();
    }
    //  查询所有课程
    @RequestMapping("findCatalog")
   public ResultResopnse findCatalog(@RequestBody CatalogDto catalogDto) {

        return feignCourse.findCatalog(catalogDto);
    }
    //学习
    @RequestMapping("xuexi")
    public Result xuexi(@RequestParam Integer catalogId, @RequestParam Integer consumerId,@RequestParam Integer courseId){
        return feignCourse.xuexi(catalogId,consumerId,courseId);
    }
    //查看用户学过哪些书了
    @RequestMapping("consumerFindAll1")
    public Result consumerFindAll1(@RequestParam Integer consumerId,@RequestParam Integer courseId){
        return feignCourse.consumerFindAll1(consumerId,courseId);
    }
    //查看用户学过哪些书了
    @RequestMapping("catalogFindAll1")
    public Result catalogFindAll1(){
        return feignCourse.catalogFindAll1();
    }
    /*
    * 分页查询竞赛    带条件查询
    * */
    @RequestMapping("raceFindAll")
    public Result raceFindAll(@RequestParam String lib,@RequestBody RaceDto raceDto){
        return feignRace.raceFindAll(lib,raceDto);
    }
    /*
    * 查询出所有的战队
    * */
    @RequestMapping("TeamFindAll")
    public Result TeamFindAll(){
        return feignConsumer.TeamFindAll();
    }
    /*
    * 报名
    * */
    @RequestMapping("addRaceTeam")
    public void addRaceTeam(@RequestBody RaceTeam raceTeam){
         feignConsumer.addRaceTeam(raceTeam);
    }

    @RequestMapping("raceTeambyOne")
    Result raceTeambyOne(@RequestBody RaceTeam raceTeam){
        return feignConsumer.raceTeambyOne(raceTeam);
    }


    @RequestMapping("TeamFindLabel")
    String TeamFindLabel(@RequestBody Race race){
        return feignLabel.TeamFindLabel(race);
    }

    /*
    * 查询参赛选手
    * */
    @RequestMapping("raceTeamById")
    Result raceTeamById(@RequestBody RaceTeam raceTeam){
        return feignConsumer.raceTeamById(raceTeam);

    }
    /*
    * 查询考试卷
    * */
    @RequestMapping("quizfindAll")
    Result quizfindAll(@RequestBody RaceTeam raceTeam){
        return feignRace.quizfindAll(raceTeam);
    }
    /*
    * 查询考试卷
    * */
    @RequestMapping("paperfindAll")
    Result paperFindAll(@RequestParam Integer id){
        return feignCategory.paperFindAll(id);
    }


    /*
    * 答题添加数据
    * */
    @RequestMapping("xzdaAdd")
    Result xzdaAdd(@RequestBody Xzda xzda){
     return feignCategory.xzdaAdd(xzda);
    }
    /*
    * 查看上一题
    * */
    @RequestMapping("zqdaById")
    Result zqdaById(@RequestBody Xzda xzda){
     return feignCategory.zqdaById(xzda);
    }

    /*
    * 提交 看看正确几道题
    * */
    @RequestMapping("tj")
    Result tj(@RequestBody Xzda xzda){
        return feignCategory.tj(xzda);
    }
    @RequestMapping("selectBysort")
    public Result selectBysort(){
        return  feignCategory.selectBysort();
    }

}
